package com.etone.smartAudit.controller;

import com.etone.smartAudit.service.AuditExceptionForeignReportService;
import com.etone.smartAudit.vo.auditExceptionCityReport.AuditExceptionCityReportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author: sovy
 * @date: 2021/2/2
 * @description:
 */
@AllArgsConstructor
@RestController
@Api(tags = "对外报告", value = "AuditExceptionForeignReportController")
public class AuditExceptionForeignReportController {

    private AuditExceptionForeignReportService auditExceptionForeignReportService;


    @ApiOperation(value = "获取所有城市列表《完》")
    @GetMapping("/foreignReports/cities")
    public List<String> findAllCity() {
        return auditExceptionForeignReportService.findAllCity();
    }

    @ApiOperation(value = "获取所有地市报告列表《完》")
    @GetMapping("/foreignReports")
    public AuditExceptionCityReportVO list(
            @ApiParam(value = "地市名称") @RequestParam(required = false) String cityName,
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        return auditExceptionForeignReportService.list(cityName, page, pageSize);
    }

    @ApiOperation(value = "下载报表《完》")
    @GetMapping("/foreignReports/export")
    @ApiImplicitParam(name = "ids", value = "ID集合", required = true, allowMultiple = true, dataType = "Array", paramType = "query", example = "[1,2]")
    public void export(
            @ApiParam(value = "ids") @RequestParam List<Integer> ids,
            @ApiParam(value = "参数字段") @RequestParam(required = false) List<String> fields,
            @ApiParam(value = "审计点参数") @RequestParam(required = false) List<String> specialKeys,
            @ApiParam(value = "月份，格式yyyy-MM") @RequestParam(required = false) String startDate,
            @ApiParam(value = "月份，格式yyyy-MM") @RequestParam(required = false) String endDate,
            HttpServletResponse response) {
        auditExceptionForeignReportService.exportReport(ids, fields, specialKeys, startDate, endDate, response);
    }
}
